﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text;

namespace GoogleMapAPI
{
    public partial class MyMapsGet : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HandleMyMapsKml();
        }

        protected void HandleMyMapsKml()
        {
            string src = Request.QueryString.ToString().TrimStart("src=".ToArray());
            src = Server.UrlDecode(src);
            if (String.IsNullOrEmpty(src))
            {
                src = "http://ditu.google.com/maps/ms?ie=UTF8&hl=zh-CN&brcurrent=3,0x31508e64e5c642c1:0x951daa7c349f366f,0%3B5,0,0&msa=0&msid=212800177725253189507.0004a07859593181e6f23&ll=38.08269,98.481445&spn=13.995455,33.815918&z=6&output=kml";
            }
            WebRequest request = WebRequest.Create(src);
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader sReader = new StreamReader(stream);
            var content = sReader.ReadToEnd();

            Response.Clear();
            Response.ContentType = "text/xml";
            Response.Write(content);
            Response.End();
        }
    }
}